class Solution8 {
    public TreeNode pruneTree(TreeNode root) {
        if(root.left != null ) root.left = pruneTree(root.left);
        if(root.right != null) root.right = pruneTree(root.right);
        if(root.left == null & root.right == null) {
            if(root.val == 0) {
                root = null;
            }
        }
        return root;
    }
}